package com.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.dao.UserDao;
import com.entity.UserInfo;

public class SearchAllServlet extends HttpServlet{
	
	UserDao dao = new UserDao();

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		List<UserInfo> userList = dao.getAll();
		
		response.setContentType("text/html;charset=utf-8");
		PrintWriter out = response.getWriter();
		out.print("<html>");
		out.print("<body>");
		out.print("<table border=2 >");
		for(UserInfo u:userList){
			out.println("<tr>");
			out.println("<td>"+u.getId()+"</td>");
			out.println("<td>"+u.getUsername()+"</td>");
			out.println("<td>"+u.getPassword()+"</td>");
			out.println("<td>"+u.getNote()+"</td>");
			out.println("</tr>");
		}
		out.print("</table>");
		out.print("</body>");
		out.print("</html>");
		
	}
	
	
	

}
